home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / Dir / Dir.rep < prev    next >
Text File  |  1999-04-21  |  3KB  |  155 lines

  1. G4C   
  2.  
  3. ; Dir.rep - GUI for the c:Rep replace command.
  4.  
  5.  
  6. ; ----------------- The window
  7.  
  8. WinBig -1 -1 400 100 'Replace in selected files'
  9. WinType 11110001
  10. varpath dir.gc
  11.  
  12. BOX    0 0 0 0 OUT ICONDROP
  13.  
  14. ; ----------------- General events
  15.  
  16. xOnLoad
  17. rp_from  = ""
  18. rp_to    = ""
  19. rp_savemode = OVER
  20. rp_ci = ""
  21. guiopen Dir.rep
  22. RUN 'resident guis:c/Rep pure add'
  23.  
  24. xOnReload
  25. guiopen dir.rep
  26.  
  27. xOnClose
  28. delvar rp_#?
  29. guiquit Dir.rep
  30. run 'resident Rep remove'
  31.  
  32. ; ---------------- text-in gadgets for entering..
  33.  
  34. xTextIn   80 5  310 18 'Replace:' rp_from "" 200    ; string to Rep
  35. gadid 1
  36. setgad dir.rep 2 on   ; activate next textin
  37.  
  38.  
  39. xTextIn   80 25 310 18 'With:' rp_to "" 200        ; Rep with this
  40. gadid 2
  41.  
  42. ; ---------------- Do we want to add extensions to the files ?
  43.  
  44. xCycler  10 45 190 14 "" rp_savemode
  45. gadid 3
  46. cstr 'OVERWRITE Files'    OVER
  47. cstr 'Add .rep extension' EXT
  48.  
  49. ; ---------------- case insensitive search ?
  50.  
  51. xCycler  200 45 190 14 "" rp_ci
  52. gadid 6
  53. cstr 'Case Sensitive'    ""
  54. cstr 'Case Insensitive'  I
  55.  
  56. ; ---------------- A text display, telling you what's going on.
  57.  
  58. TEXT 15 65 50 14 Status: 20 NOBOX
  59.  
  60. TEXT 80 65 310 14 Waiting.. 100 BOX
  61. gadid 4
  62.  
  63. ; ---------------- Start converting..
  64.  
  65. xButton 210 80 90 14 Start
  66. gadid 5
  67. lvmulti first
  68. if $lv_file = ""
  69.    ezreq "No files selected!" OK ''
  70.    stop
  71. endif
  72. if $$LV_TYPE != FILE
  73.    ezreq 'Directories can not\nbe converted!\n\nTry again..\n' OK ""
  74.    stop 
  75. endif
  76. if $rp_from = ""
  77.    ezreq 'No "Replace:" defined!' OK ""
  78.    stop
  79. endif
  80. rp_flag = 0
  81. rp_destfile = ""
  82. if $rp_savemode = EXT
  83.    extract lv_file UNQUOTE rp_fname
  84.    appvar  rp_fname .rep
  85.    rp_destfile = \"$rp_fname\"
  86. endif
  87. gosub dir.rep disable
  88. update Dir.rep 4 'REP: $lv_file'
  89. set deeptrans off
  90. launch 5 'Rep $lv_file \"$rp_from\" \"$rp_to\" $rp_destfile $rp_ci'
  91. set deeptrans on
  92.  
  93. ; Use of the launch command will allow the other GUIs running on
  94. ; this instance of Gui4Cli to go about their business normally
  95.  
  96. xOnReturn 5
  97. update Dir.rep 4 'Finished.'
  98. lvmulti OFF            ; set selection off
  99. if $rp_flag != 0          ; check abort flag
  100.    rp_flag = 0            ; reset for next time
  101.    gosub dir.rep enable
  102.    stop
  103. endif
  104. lvmulti next            ; get next file
  105. if $lv_file = ""        ; no more files
  106.    lvdir refresh
  107.    gosub dir.rep enable
  108.    stop
  109. endif
  110. if $rp_savemode = EXT
  111.    extract lv_file UNQUOTE rp_fname
  112.    appvar  rp_fname .rep
  113.    rp_destfile = \"$rp_fname\"
  114. endif
  115. update Dir.rep 4 'REP: $lv_file'
  116. set deeptrans off
  117. launch 5 'Rep $lv_file \"$rp_from\" \"$rp_to\" $rp_destfile $rp_ci'
  118. set deeptrans on
  119.  
  120.  
  121. ; --------------- Cancel the rest of the files chosen.
  122.  
  123.  
  124. xButton 300 80 90 14 Stop
  125. setvar rp_flag 1
  126.  
  127. ; --------------- Routines to disables & enable guis
  128.  
  129. xRoutine disable
  130. guiwindow dir.gc wait
  131. setgad dir.rep 1 off
  132. setgad dir.rep 2 off
  133. setgad dir.rep 3 off
  134. setgad dir.rep 5 off
  135. setgad dir.rep 6 off
  136.  
  137. xRoutine enable
  138. guiwindow dir.gc resume
  139. setgad dir.rep 1 on
  140. setgad dir.rep 2 on
  141. setgad dir.rep 3 on
  142. setgad dir.rep 5 on
  143. setgad dir.rep 6 on
  144.  
  145. xOnFail
  146. gosub dir.rep enable
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.